package com.lxc.entity;

import lombok.Data;

@Data
public class Result<T> {

    private Integer code; //状态码

    private String msg; //提示信息

    private T data; //数据

    private long timestamp;//接口请求时间

    public Result() {
        this.timestamp = System.currentTimeMillis();
    }

    public static <T> Result<T> success(T data) {
        Result<T> Result = new Result<>();
        Result.setCode(ReturnCode.RC200.getCode());
        Result.setMsg(ReturnCode.RC200.getMsg());
        Result.setData(data);
        return Result;
    }

    public static <T> Result<T> error(int code, String msg) {
        Result<T> Result = new Result<>();
        Result.setCode(code);
        Result.setMsg(msg);
        Result.setData(null);
        return Result;
    }
}
